<!DOCTYPE html>
<html>
<head>
    <include file="Include:meta"/>
    <title>添加项目-目的地运营集团数据管理平台</title>
    <include file="Include:style"/>
    <style>
        .w50 {
            width: 50px;
        }
    </style>
    <script src="__PUBLIC__/js/select/jquery.multi-select.js"></script>
</head>
<body>
<include file="Include:header"/>
<include file="Include:left"/>
<div id="main">
    <div class="crumbs">
        <div class="crumbs-text">项目列表 > 添加项目</div>
    </div>
    <div id="content">
        <form action="__APP__/CrmProjects/add" method="post" id="crmprojects_add_form">
            <div class="form-main">
                <div class="form-title">添加项目</div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>关联商务项目</div>
                    <div class="input-item">
                        <select name="projects_id" class="form-control w400 required_select" autocomplete="off"
                                required>
                            <option value="">全部</option>
                            <foreach name="res_crm_project" item="vo">
                                <option value="{$vo.project_id}">{$vo.name}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>项目编号</div>
                    <div class="input-item">
                        <input type="hidden" class="form-control w400" name="project_id" autocomplete="off" readonly>
                        <input type="text" class="form-control w400" name="project_num" autocomplete="off" readonly>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>项目名称</div>
                    <div class="input-item">
                        <input type="text" class="form-control w400" name="project_name" autocomplete="off" readonly>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>项目简称</div>
                    <div class="input-item">
                        <input type="text" class="form-control w400" name="short_name" autocomplete="off" readonly>
                        <span class="error-item">必填项</span>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>关联部门</div>
                    <div class="input-item">
                        <select name="department_id" class="form-control w400 required_select" autocomplete="off"
                                required>
                            <foreach name="res_department" item="vo">
                                <option value="{$vo['DEPTID']}">{$vo['HPS_DEPT_FULLDESCR']}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>项目负责人</div>
                    <div class="input-item">
                        <select name="leader" class="form-control w200 required_select" autocomplete="off"
                                required>
                            <option value="{:$_SESSION['dms_uid']}">{:$_SESSION['dms_username']}</option>
                            <foreach name="user_list" item="vo">
                                <option value="{$vo.id}">{$vo.username}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>项目群负责人</div>
                    <div class="input-item">
                        <select name="group_leader" class="form-control w200 required_select" autocomplete="off"
                                required>
                            <option value="{:$_SESSION['dms_uid']}">{:$_SESSION['dms_username']}</option>
                            <foreach name="user_list" item="vo">
                                <option value="{$vo.id}">{$vo.username}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>添加联系人</div>
                    <div class="input-item">
                        <select name="main_linkman" class="form-control w200"
                                autocomplete="off" required>
                            <option value="-10">请选择</option>
                            <foreach name="res_contact" item="vo">
                                <option value="{$vo['contact_id']}">{$vo['username']}-{$vo['mobilephone']}</option>
                            </foreach>
                        </select>
                        <button type="button" class="btn add_cus" refresh=0>添加客户</button>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>状态</div>
                    <div class="input-item">
                        <for start="1" end="6" comparison="elt">
                            <label class="radio-inline" for="stage{$i}">
                                <input type="radio" name="stage" id="stage{$i}" value="{$i}">{:get_projects_stage($i)}
                            </label>
                        </for>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label"><span class="asterisk">*</span>启动日期</div>
                    <div class="input-item">
                        <input type="text" name="start_date" class="form-control Wdate w100 required_text"
                               onClick="WdatePicker()" autocomplete="off" value="{$today}" readonly><span class="error-item">必填项</span>
                    </div>
                </div>
                <div class="form-item">
                    <div class="input-label">备注</div>
                    <div class="input-item">
                        <textarea name="remark" class="form-control w400" autocomplete="off"></textarea>
                    </div>
                </div>

            </div>
            <div class="form-btn-item"><input type="submit" value="提交" class="btn btn-submit">
                <button class="btn btn-default goback" type="button">返回</button>
            </div>
        </form>
    </div>
</div>
<!--弹出框-->
<include file="Crm:contact_ajax_add"/>
</body>
<include file="Include:javascript"/>
<include file="Crm:javascript_contact"/>
<script type="text/javascript">
    $(function () {
        /*拓展项目联动运营项目*/
        $("[name='projects_id']").change(function () {
            $('#submit').show();
            var val = $(this).val();
            if (val == -10) {
                $('#contract_id,#make_money,#back_id,#back').html('');
            } else {
                $.ajax({
                    type: "GET",
                    async: false,
                    dataType: "json",
                    data: {"project_id": val},
                    url: "__APP__/CrmProject/getCrmProjectAjax",
                    success: function (data) {
                        if (data) {
                            $("[name='project_id']").val(data.project_id);
                            $("[name='project_num']").val(data.project_num);
                            $("[name='project_name']").val(data.name);
                            $("[name='short_name']").val(data.short_name);
                        } else {
                            defeated_alert('没有关联合同信息')
                        }
                    }
                })
            }
        })
    });
</script>
</html>